import { ref } from 'vue'
import { exportSettlementList } from '@/api/withdrawal'

/**
 * 导出结算
 */
export const useExportSettlement = () => {
  // 导出加载
  const exportLoading = ref(false)

  // 导出筛选条件
  const exportFilter = ref<FinanceAPIRequest.ExportSettlementList>({
    dateType: null,
    endTime: '',
    engineer: '',
    fieldType: 1,
    keyword: '',
    limit: 50,
    networkId: '',
    page: 1,
    startTime: '',
    workNo: '',
  })

  /**
   * 获取导出数据
   */
  const getExportData = async () => {
    exportLoading.value = true
    const res = await exportSettlementList(exportFilter.value)
    exportLoading.value = false
    return res.data
  }

  return {
    exportFilter,
    exportLoading,
    getExportData,
  }
}
